package com.ity.teamanagement.controller;

import com.ity.teamanagement.entity.inputParam.ScreenParam;
import com.ity.teamanagement.result.Result;
import com.ity.teamanagement.service.TeaSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author coderFu
 * @create 2021/5/23
 */
@RestController
@Api(tags ="前台搜索模块")
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private TeaSearchService teaSearchService;

    @GetMapping("/findTeaListByCondition")
    @ApiOperation("根据条件查询茶种信息")
    public Result findTeaListByCondition(ScreenParam screenParam, @PageableDefault(page = 0,size = 10)Pageable pageable){
        return Result.success(teaSearchService.findTeaListByCondition(screenParam,pageable));
    }

//    @GetMapping("/findTeaList")
//    @ApiOperation("查询所有茶种列表")
//    public Result findTeaList(@PageableDefault(page = 0,size = 10) Pageable pageable){
//        return Result.success(teaSearchService.findTeaList(pageable));
//    }

    @GetMapping("/findTeaDetailsMessageById")
    @ApiOperation("根据茶种id查询茶种详情信息（主信息）")
    public Result findTeaDetailsMessageById(@RequestParam("id") Long id){
        return Result.success(teaSearchService.findTeaDetailsMessageById(id));
    }

    @GetMapping("/findRemarksTeaDetailsMessageById")
    @ApiOperation("根据茶种id查询茶种详情信息（附加信息）")
    public Result findRemarksTeaDetailsMessageById(@RequestParam("id") Long id){
        return Result.success(teaSearchService.findRemarksTeaDetailsMessageById(id));
    }


}
